cf_host = sw5f90 -host 
cf_slave = sw5f90 -slave -openmp
cf_hybrid = sw5f90 -hybrid 
cc=sw5cc -host 
cc_slave=sw5cc -slave
FC = mpif90

SCHEDULER_INSTALL_PATH=${DAG_HOME}/dag_task_scheduler

EXTRA_FLAGS= -D_PROFILING -DCHECK #-OPT:alias=cray_pointer -D_UNROLL#-OPT:alias=cray_pointer #-D_UNROLL -D_LDMM #-D_MMEM  
PERF_FLAGS= -lswperf
CFLAG = -cpp -O2 #-S#-C
CFLAGS = $(EXTRA_FLAGS) $(CFLAG) -I${SCHEDULER_INSTALL_PATH}/include -L${SCHEDULER_INSTALL_PATH}/lib

FFFLAG = -I${SCHEDULER_INSTALL_PATH}/include 

LIBFLAGS =  -L/usr/sw-mpp/lib -ldag_task_scheduler -lstdc++ -lm -lm_slave  #-lswperf


SWDAG_OBJS = dag_2d5p_master.o \
			 dag_2d5p_slave.o \
			 dag_parallel.o \
			 dag_2d5p_neighbor.o \
			 reply_wait.o
 
DAG_EXE = swdag_2d5p

all: $(DAG_EXE)

 $(DAG_EXE): $(SWDAG_OBJS)
	$(cf_hybrid) $(CFLAGS) $(PERF_FLAGS) -o swdag_2d5p rtcc.o DMA_getid.o $(SWDAG_OBJS) $(LIBFLAGS) $(PERF_FLAGS)
#dag_2d5p_main.o: dag_2d5p_main.f90
#	$(cf_host) $(CFLAGS)  -c dag_2d5p_main.f90  $(LIBFLAGS)
dag_2d5p_master.o: dag_parallel.o dag_2d5p_master.f90
	$(cf_host) $(CFLAGS)  -c dag_2d5p_master.f90  $(LIBFLAGS)
dag_2d5p_slave.o: dag_parallel.o rtcc.o DMA_getid.o dag_2d5p_slave.f90
	$(cf_slave) $(CFLAGS)  -c dag_2d5p_slave.f90  $(LIBFLAGS) 
dag_parallel.o: dag_parallel.f90
	$(FC) $(CFLAGS) -c -o dag_parallel.o dag_parallel.f90
dag_2d5p_neighbor.o: dag_parallel.o  dag_2d5p_neighbor.f90
	$(cf_host) $(CFLAGS) -c -o dag_2d5p_neighbor.o dag_2d5p_neighbor.f90
reply_wait.o:reply_wait.f90
	$(cf_slave) -O0 -c -o reply_wait.o reply_wait.f90
rtcc.o:rtcc.c
	$(cc_slave) $(CFLAGS) -c -o rtcc.o rtcc.c
DMA_getid.o:DMA_getid.c
	$(cc_slave) $(CFLAGS) -c -o DMA_getid.o DMA_getid.c
clean:
	rm -f $(SWDAG_OBJS) *.o swdag_2d5p *.mod

